home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
029a
/
masview.zip
/
TTT1.C
< prev
next >
Wrap
Text File
|
1991-10-23
|
864b
|
45 lines
/* ttt1.c - main module */
#include "stdio.h"
#include "ttt.h"
char board[ 3 ][ 3 ]; /* playing board, global 2-dimension array */
main() /* main program */
{
int turn;
char s[ 80 ];
printf( "Welcome to Tic-Tac-Toe... you will be 'X'\n\n" );
printf( "Do you want to go first? (Y/N) " );
gets( s );
if ( tolower( s[ 0 ] ) == 'y' )
turn = HUMAN;
else turn = COMPUTER;
for ( set_up_board(); ! game_over( board ); print_board() )
switch( turn )
{
case COMPUTER:
computer_move();
turn = HUMAN;
break;
case HUMAN:
human_move();
turn = COMPUTER;
break;
default:
break;
}
}
static set_up_board() /* set up the playing board to be empty and print it */
{
int x, y;
for ( x = 0; x < 3; ++x )
for ( y = 0; y < 3; ++y )
board[ x ][ y ] = EMPTY;
print_board();
}